import { useSize } from "ahooks";
import { RefObject, useEffect } from "react";

export default function SizeLogic({elementRef}: {elementRef: RefObject<HTMLDivElement>}){

  const size = useSize(elementRef);

  useEffect(() => {
    if(size?.height){
      parent.postMessage({
        type: 'windowHeightOnChange',
        data: {
          height: size.height
        }
      },'*')
    }
  }, [size?.height]);

  return null;
}
